<%--

<!------------------------------------------------------------------------------
 - Copyright 2006 CORE Solutions Limited
 - All rights reserved.
 - PROPRIETARY AND CONFIDENTIAL INFORMATION.
 - Use is subject to license terms.
 -
 - FUNCTION ID      :   USER
 - AUTHOR           :   Victor Zheng 
 - DATE CREATE      :   2006/02/01
 - DESCRIPTION      :   a MAINTENANCE CONTENT JSP file for the function, USER
 -                  :   
 -                  :   
 -                  :   
 -
 - MODIFICATION HISTORY:
 - DATE         AUTHOR          VERSION NO.         COMMENT
 - -----------  --------------  ------------------  -------------------
 - 2006/02/01   Victor Zheng    1.0                 source is generated.
 -
 -
 -
------------------------------------------------------------------------------->

--%>
<%@ include file="/jsp/com/erp/app/common/jsp/directives_include.jsp"%>

<%@ page import="com.erp.app.admin.userSetup.vo.UserVo"%>
<%@ page import="com.erp.app.admin.userSetup.web.UserMaintenanceAction"%>
<%@ page import="com.erp.app.util.web.TabInfo"%>

<%@ include file="/jsp/com/erp/app/common/jsp/html_include.jsp"%>

<jsp:useBean id="userMaintenanceForm" scope="session" type="com.erp.app.admin.userSetup.web.UserMaintenanceForm" />

<script language="javascript">

	function doViewImage(pageEvent) {
		var w = window.open("userMaintenance.do?pageEvent=" + pageEvent, "view", "toolbar=no,scrollbars=1,resizable=1,statusbar=no,menubar=no,width=640,height=400,top=0,left=0");
	}

	function doViewSignatureImage(pageEvent,pageEventSrc) {
		var w = window.open("userMaintenance.do?pageEvent=" + pageEvent + "&pageEventSrc=" + pageEventSrc, "view", "toolbar=no,scrollbars=1,resizable=1,statusbar=no,menubar=no,width=640,height=400,top=0,left=0");
	}
		
	
	function doLoad() {
		<%
		if (CommonUtil.nullToString((String)session.getAttribute(ProjectConstants.SESSION_ALERT_AFTER_SAVE)).equals(ProjectConstants.GENERIC_YES)) {
			session.removeAttribute(ProjectConstants.SESSION_ALERT_AFTER_SAVE);
			out.println("alert('Records saved.');");
		} 
		String alertMsg = CommonUtil.nullToString(session.getAttribute(ProjectConstants.SESSION_ALEADY_EXISTS_ACCESS_TEAM));
		String alertBuyerMsg = CommonUtil.nullToString(session.getAttribute(ProjectConstants.SESSION_ALEADY_EXISTS_BUYER));
		String alertBrandMsg = CommonUtil.nullToString(session.getAttribute(ProjectConstants.SESSION_ALEADY_EXISTS_BRAND));
		String alertNtTeamMsg = CommonUtil.nullToString(session.getAttribute(ProjectConstants.SESSION_ALEADY_EXISTS_NT_TEAM));
		if (!CommonUtil.isEmpty(alertMsg)){
			session.removeAttribute(ProjectConstants.SESSION_ALEADY_EXISTS_ACCESS_TEAM);
			out.println("alert('" + alertMsg + " are not added, cause they are already exists');");
		} else if (!CommonUtil.isEmpty(alertBuyerMsg)){
			session.removeAttribute(ProjectConstants.SESSION_ALEADY_EXISTS_BUYER);
			out.println("alert('" + alertBuyerMsg + " are not added, cause they are already exists');");
		} else if (!CommonUtil.isEmpty(alertBrandMsg)){
			session.removeAttribute(ProjectConstants.SESSION_ALEADY_EXISTS_BRAND);
			out.println("alert('" + alertBrandMsg + " are not added, cause they are already exists');");
		} else if (!CommonUtil.isEmpty(alertNtTeamMsg)){
			session.removeAttribute(ProjectConstants.SESSION_ALEADY_EXISTS_NT_TEAM);
			out.println("alert('" + alertNtTeamMsg + " are not added, cause they are already exists');");
		}
		%>

		<%
		String lastAction = CommonUtil.nullToString(userMaintenanceForm.getPageEvent());
		if (lastAction.equalsIgnoreCase(UserMaintenanceAction.ACTION_ADD_ATTACH)) {
			out.println(WebUtil.openUploadFileDo());
		}else	if(lastAction.startsWith(ProjectConstants.ACTION_SPEDIT)) {
			out.println(WebUtil.openSelectRemarkTextDo());
		}else if(lastAction.equalsIgnoreCase(UserMaintenanceAction.ACTION_ADD_SIGNATURE_ATTACH)) {
			out.println(WebUtil.openUploadFileDo());
		} else if (lastAction.equals(UserMaintenanceAction.ACTION_ADD_ACCESS_TEAM)) {
			out.println(WebUtil.openSearchDo());
		} else if (lastAction.equals(UserMaintenanceAction.ACTION_ADD_BUYER)) {
			out.println(WebUtil.openSearchDo());
		} else if (lastAction.equals(UserMaintenanceAction.ACTION_ADD_BRAND)) {
			out.println(WebUtil.openSearchDo());
		} else if (lastAction.equals(UserMaintenanceAction.ACTION_ADD_NT_TEAM)) {
			out.println(WebUtil.openSearchDo());
		}
		
		%>
	}

</script>

<body onLoad="javascript:doLoad();">
<html:form action="/userMaintenance">

<html:hidden property="pageEvent"/>
<html:hidden property="pageMode"/>
<html:hidden property="deleteIdx"/>
<html:hidden property="pageEventSrc"/>

<table class="table_button">

<tr>
	<td>
		<chtml:button form="userMaintenanceForm" pageEvent="<%=UserMaintenanceAction.ACTION_EXIT%>"
			styleClass="button1"/>
		<chtml:button form="userMaintenanceForm" pageEvent="<%=UserMaintenanceAction.ACTION_SEARCH%>"
			styleClass="button1"/>
		<chtml:button form="userMaintenanceForm" pageEvent="<%=UserMaintenanceAction.ACTION_CREATE%>"
			styleClass="button1"/>
		<chtml:button form="userMaintenanceForm" pageEvent="<%=UserMaintenanceAction.ACTION_SAVE%>"
			styleClass="button1"/>
	<logic:notEqual name = "userMaintenanceForm" property = "pageMode" value = "<%=userMaintenanceForm.PAGE_MODE_CREATE%>">
		<chtml:button form="userMaintenanceForm" pageEvent="<%=UserMaintenanceAction.ACTION_REFRESH%>"
			styleClass="button1"/>
		<chtml:button form="userMaintenanceForm" pageEvent="<%=UserMaintenanceAction.ACTION_DELETE%>"
			styleClass="button1"/>
		<chtml:button form="userMaintenanceForm" pageEvent="<%=UserMaintenanceAction.ACTION_COPY%>"
			styleClass="button1"/>
	</logic:notEqual>
	</td>
</tr>

</table>

<font color='red'><html:errors /></font>

<div id="tabsF"><ul><%

TableSchema ts = userMaintenanceForm.getTs();
TabInfo[] tabInfos = tabInfos = new TabInfo[] {
	new TabInfo()
		.setFolderIdx(UserMaintenanceAction.TAB_IDX_HDR)
        .setPageEvent(UserMaintenanceAction.ACTION_CHANGE_FOLDER_HDR)
        .setTitle(ts.getDisplayWebLabelByObjectId("LBL_TAB_USER"))
        .setHidden(false)
        .setTabJsp("UserTab.jsp"),
};

TabInfo currentTab = null;
System.out.println(tabInfos.length);
for (int i = 0; i < tabInfos.length; ++i) {
	if (userMaintenanceForm.getFolderIdx().equals(String.valueOf(i))) {
		currentTab = tabInfos[i];
	}
	if (tabInfos[i].isHidden()) continue;
	%><chtml:button useExtensions="true" uiType="tab" form="userMaintenanceForm" pageEvent="<%=tabInfos[i].getPageEvent()%>" pageEventSrc="<%=String.valueOf(i)%>" /><%
}

%></ul></div><%
%><div class="titlebar"><span class="headertitletext"><%=currentTab.getTitle()%></span></div>
<div class="maintenance_content">
<logic:notEqual name="userMaintenanceForm" property="folderIdx" value="0">		
	<jsp:include page="UserCommon.jsp" flush="true"/>
</logic:notEqual>
<jsp:include page="<%=currentTab.getTabJsp()%>" flush="true"/>
</div>

</html:form>
